/*******************************************************************************
 * Copyright (c) 2015 Soyatec and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Soyatec - initial API and implementation
 *******************************************************************************/
/**
 */
package org.soyatec.tooling.di.provider;

import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.soyatec.tooling.di.DiPackage;
import org.soyatec.tooling.di.GradientShape;

/**
 * This is the item provider adapter for a
 * {@link org.soyatec.tooling.di.GradientShape} object. <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated
 */
public class GradientShapeItemProvider extends ShapeItemProvider {
    /**
     * This constructs an instance from a factory and a notifier. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    public GradientShapeItemProvider(final AdapterFactory adapterFactory) {
        super(adapterFactory);
    }

    /**
     * This returns the property descriptors for the adapted class. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    @Override
    public List<IItemPropertyDescriptor> getPropertyDescriptors(
            final Object object) {
        if (itemPropertyDescriptors == null) {
            super.getPropertyDescriptors(object);

            addUsingGradientPropertyDescriptor(object);
            addGradientColorPropertyDescriptor(object);
            addVerticalGradientPropertyDescriptor(object);
        }
        return itemPropertyDescriptors;
    }

    /**
     * This adds a property descriptor for the Using Gradient feature. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    protected void addUsingGradientPropertyDescriptor(final Object object) {
        itemPropertyDescriptors.add(createItemPropertyDescriptor(
                ((ComposeableAdapterFactory) adapterFactory)
                        .getRootAdapterFactory(),
                getResourceLocator(),
                getString("_UI_GradientShape_usingGradient_feature"),
                getString("_UI_PropertyDescriptor_description",
                        "_UI_GradientShape_usingGradient_feature",
                        "_UI_GradientShape_type"),
                DiPackage.Literals.GRADIENT_SHAPE__USING_GRADIENT, true, false,
                false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
    }

    /**
     * This adds a property descriptor for the Gradient Color feature. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    protected void addGradientColorPropertyDescriptor(final Object object) {
        itemPropertyDescriptors
                .add(createItemPropertyDescriptor(
                        ((ComposeableAdapterFactory) adapterFactory)
                                .getRootAdapterFactory(),
                        getResourceLocator(),
                        getString("_UI_GradientShape_gradientColor_feature"),
                        getString("_UI_PropertyDescriptor_description",
                                "_UI_GradientShape_gradientColor_feature",
                                "_UI_GradientShape_type"),
                        DiPackage.Literals.GRADIENT_SHAPE__GRADIENT_COLOR,
                        true, false, false,
                        ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
    }

    /**
     * This adds a property descriptor for the Vertical Gradient feature. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    protected void addVerticalGradientPropertyDescriptor(final Object object) {
        itemPropertyDescriptors.add(createItemPropertyDescriptor(
                ((ComposeableAdapterFactory) adapterFactory)
                        .getRootAdapterFactory(),
                getResourceLocator(),
                getString("_UI_GradientShape_verticalGradient_feature"),
                getString("_UI_PropertyDescriptor_description",
                        "_UI_GradientShape_verticalGradient_feature",
                        "_UI_GradientShape_type"),
                DiPackage.Literals.GRADIENT_SHAPE__VERTICAL_GRADIENT, true,
                false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null,
                null));
    }

    /**
     * This returns the label text for the adapted class. <!-- begin-user-doc
     * --> <!-- end-user-doc -->
     *
     * @generated
     */
    @Override
    public String getText(final Object object) {
        final String label = ((GradientShape) object).getId();
        return label == null || label.length() == 0 ? getString("_UI_GradientShape_type")
                : getString("_UI_GradientShape_type") + " " + label;
    }

    /**
     * This handles model notifications by calling {@link #updateChildren} to
     * update any cached children and by creating a viewer notification, which
     * it passes to {@link #fireNotifyChanged}. <!-- begin-user-doc --> <!--
     * end-user-doc -->
     *
     * @generated
     */
    @Override
    public void notifyChanged(final Notification notification) {
        updateChildren(notification);

        switch (notification.getFeatureID(GradientShape.class)) {
        case DiPackage.GRADIENT_SHAPE__USING_GRADIENT:
        case DiPackage.GRADIENT_SHAPE__GRADIENT_COLOR:
        case DiPackage.GRADIENT_SHAPE__VERTICAL_GRADIENT:
            fireNotifyChanged(new ViewerNotification(notification,
                    notification.getNotifier(), false, true));
            return;
        }
        super.notifyChanged(notification);
    }

    /**
     * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
     * describing the children that can be created under this object. <!--
     * begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated
     */
    @Override
    protected void collectNewChildDescriptors(
            final Collection<Object> newChildDescriptors, final Object object) {
        super.collectNewChildDescriptors(newChildDescriptors, object);
    }

}
